package com.example.block_chain.controller.classs;


import com.example.block_chain.common.ResponseResult;
import com.example.block_chain.domain.dto.ClassDto;
import com.example.block_chain.domain.pojo.Class;
import com.example.block_chain.service.classs.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class ClassController {

    @Autowired
    private ClassService classService;

    @PostMapping("/add/class/")
    private ResponseResult addClass(@RequestBody ClassDto dto) {
        return classService.addClass(dto);
    }

    @PostMapping("/delete/class/")
    private ResponseResult deleteClass(@RequestBody ClassDto dto) {
        return classService.deleteClass(dto);
    }

    @PostMapping("/update/class/")
    private ResponseResult updateClass(@RequestBody ClassDto dto) {
        return classService.updateClass(dto);
    }

    @PostMapping("/select/class/")
    private ResponseResult selectClass(@RequestBody ClassDto dto) {
        return classService.selectClass(dto);
    }

    @GetMapping("/select/class")
    private ResponseResult selectClass(@RequestParam String facultyCode, @RequestParam String schoolCode) {
        List<Class> classes = classService.selectClass(facultyCode, schoolCode);
        return ResponseResult.okResult(classes);
    }
}
